﻿using nplJobsBLL.ProcessSelectJobSeeker;
using nplJobsCommon.JobSeeker;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class EmployeeMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Header.DataBind();

        if (Session["userType"] == null)
        {
            Response.Redirect("~/Default.aspx");
        }

        else if (Session["userType"].ToString() == TypeOfUser.UserType.Employeer.ToString())
        {
            Response.Redirect("~/Default.aspx");
            Session["userType"] = null;
        }
        else
        {
            MembershipUser userInfo = (MembershipUser)Session["userInfo"];

            Guid userID = (Guid)userInfo.ProviderUserKey;

            JobSeeker jobSeeker = GetJobSeeker(userID);

            lblUserName.Text = jobSeeker.FirstName + " " + jobSeeker.LastName;
        }

    }

    #region GetJobSeeker
    private JobSeeker GetJobSeeker(Guid jobSeekerId)
    {
        JobSeeker jobSeeker = new JobSeeker();
        ProcessSelectJobSeeker selectJobSeeker = new ProcessSelectJobSeeker();

        selectJobSeeker.JobSeekerID = jobSeekerId;
        selectJobSeeker.invoke();

        if (selectJobSeeker.JobSeeker != null)
        {
            jobSeeker = selectJobSeeker.JobSeeker.FirstOrDefault();
        }

        return jobSeeker;
    }
    #endregion
}
